package ui;
import java.awt.BorderLayout;
import java.util.ArrayList;

import javax.swing.JTextArea;

import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import dto.LineBillDTO;
import dto.LineDTO;
import dto.PlanDTO;
import dto.PlanItemDTO;
import dto.ServiceDTO;
import dto.UserDTO;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ListPlanView extends javax.swing.JFrame {
	private JTextArea jTextAreaBill;
	private JScrollPane srollPanel;
	private ArrayList<PlanDTO> plans;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ListPlanView inst = new ListPlanView();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ListPlanView() {
		super();
	}

	
	public ListPlanView(ArrayList<PlanDTO> plans) {
		super();
		this.plans = plans;
		initPlanGUI();
	}

	
	private void initPlanGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jTextAreaBill = new JTextArea();
				srollPanel = new JScrollPane(jTextAreaBill); 
				//getContentPane().add(jTextAreaBill, BorderLayout.CENTER);
				getContentPane().add(srollPanel, BorderLayout.CENTER);
				for (PlanDTO plan  : plans) {
					
					
					jTextAreaBill.append("Name: "+plan.getPlanNumber()+"\n");
					jTextAreaBill.append("Cost: "+plan.getPlanCost()+"\n");
					jTextAreaBill.append("Discount: "+plan.getDiscount()+"\n");
					jTextAreaBill.append("*****************************"+"\n");
					for (PlanItemDTO item: plan.getPlanItems()){
						jTextAreaBill.append("Service Name:"+item.getServiceName()+"\n");
						jTextAreaBill.append("Service Free units :"+item.getServiceFreeUnits()+"\n");
						jTextAreaBill.append("Service Cost:"+item.getServiceCost()+"\n");
						jTextAreaBill.append("*****************************"+"\n");	
					}
					jTextAreaBill.append("-----------------------------"+"\n");
				}
//				
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
